<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    (function () {
        function Tank() {
            this.dom = null
            this.speed = 0
            this.pic = ''
            this.move = function () {

            }
        }
        var instance = null
        function getInstance() {
            return instance ? instance : (instance = new Tank())
        }
             //给window对象添加一个属性( 将 onlyOne 暴露到外部)
        // window.onlyOne = { getInstance }
        //window对象身上的所有属性 在使用的时候 都可以省略 window. 前缀
        onlyOne = { getInstance }
    })()

    var d = onlyOne.getInstance()
    var e = onlyOne.getInstance()
    
console.log(d,e);
    console.log(d==e);
</script>